//子类互斥属性
interface Man1 {
  fortune: string;
}
interface Man2 {
  funny: string;
}
interface Man3 {
  foreign: string;
}
type Mantype = Man1 | Man2 | Man3; //我的希望是Mantype只能是其中一种类型，现在这种实现是3种类型都可以
const man: Mantype = {
  fortune: "2",
  funny: "2",
  foreign: "2",
};

//1、把每一个man添加一个其他man的属性，是可选，值必须是never，就可以实现是Mantype只能是其中一种类型----------------------------------

interface Man11 {
  fortune: string;
  funny?: never;
  foreign?: never;
}
interface Man21 {
  funny: string;
  fortune?: never;
  foreign?: never;
}
interface Man31 {
  foreign: string;
  fortune?: never;
  funny?: never;
}
type Mantype1 = Man11 | Man21 | Man31; //我的希望是Mantype1只能是其中一种类型，现在这种实现是3种类型都可以
const man1: Mantype1 = {
  foreign: "2",
};

//2、----------------------------------
//核心就是排除你的属性，在我的类型里面加上你的属性，值是never
//man1-man2:将man1的属性标记成never+man2
//man2-man1:将man2的属性标记成never+man1
type DisCardType<T, U> = { [K in Extract<keyof T, keyof U>]?: never };

type OrType<T, U> = (DisCardType<T, U> & U) | (DisCardType<U, T> & T);
type manType3 = OrType<Man3,OrType<Man1, Man2>>;

const man2: Mantype1 = {
    foreign: "2",
  };
